﻿using System;
using System.Collections.Generic;
using SobrietyEngine.UDMF;
using SobrietyEngine.Actor;
using SobrietyEngine.Components.Common;
using SobrietyEngine.Components.Graphic;
using SobrietyEngine.Physics;
using SobrietyEngine.Scene;
using SobrietyEngine.Guids;
using Microsoft.Xna.Framework;

namespace SobrietyEngine.Actor.Builders.UDMF
{
    public class UDMFWallQuadBldr:BaseActorBuilder
    {

        public static IActor Build(IScene scene, CGuid mapActorGuid, Vector3[] verts, string texture)
        {
            IActor actor = scene.CreateEmptyActor();
            actor.AttachComponent(new PositionCmp(new Vector3(0, 0, 0)));
            actor.AttachComponent(new OrientationCmp());
            actor.AttachComponent(new SobrietyEngine.Components.SceneGraph.SceneNodeCmp(mapActorGuid));

            //ok, lets try to create a wall texture at the linesegment
            Vector3[] quad = new Vector3[4];
            quad[0] = verts[0] ; //LL
            quad[1] = verts[1]; //UL

            quad[2] = verts[2] ; //LR
            quad[3] = verts[3]; //UR

            actor.AttachComponent(new TexturedQuadCmp(texture, quad));

            actor.Initialize();

            return actor;
        }
    }
}
